<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
			$(function() {
				$("#datepicker").datepicker({
					showWeek : true,
					firstDay : 1,
					dateFormat : 'yy-mm-dd',
					defaultDate : $("#startDate").val(),
					showOtherMonths : true,
					selectOtherMonths : true,
					onSelect : function(dateText) {
						var url = $("#baseUrl").val();
						url += ("&startDate=" + dateText);

						location = url;
					}
				});

				$("#cbSingle").click(function() {
					var url = $("#noSingleBaseUrl").val();
					if (this.checked) {
						url += ("&single=single");
					}

					location = url;
				});
			});
		</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<input value="${startDate}" id="startDate" type="hidden" />
		<input value="${baseUrl}" id="baseUrl" type="hidden" />
		<input value="${noSingleBaseUrl}" id="noSingleBaseUrl" type="hidden" />
		<div class="row-fluid">
			<div class="span8">
				<div class="well well-small clearfix">
					<div class="pull-left">
						<div id="datepicker"></div>
					</div>
					<fieldset style="margin-left: 280px">
						<legend style="margin-bottom: 0px">
							选择课程<small>双击课程进行选择</small>
							<a class="btn btn-small btn-danger" href="<s:property value="createClearUrl(#orderLessonQuery)"/>">清空</a>
							<span class="form-inline"> <label class="checkbox">
									<input name="single" value="single" type="checkbox" <s:if test="#orderLessonQuery.single">checked="checked" </s:if> id="cbSingle">单选模式
								</label>
							</span>
						</legend>
						<dl id="lessons">
							<dt></dt>
							<dd>
								<ul class="unstyled">
									<s:iterator value="selected" var="lesson">
										<li><a href="<s:property value="createRemoveUrl(#lesson,#orderLessonQuery)" />">
												<span class="label label-info">${lesson.timespan}</span> <strong>${lesson.name}</strong> <span class="text-success"> <s:iterator value="teachings" var="teaching"
														status="status">${teaching.teacher.name}
										<s:if test="!#status.last">,</s:if>
													</s:iterator>
												</span> ${lesson.classroom.name }
											</a></li>
									</s:iterator>
								</ul>
							</dd>
						</dl>
					</fieldset>
				</div>
				<table class="table table-hover" style="cursor: pointer;">
					<thead>
						<tr>
							<th>Time</th>
							<th>Lesson</th>
							<th>Teacher</th>
							<th>Classroom</th>
							<th>Listener</th>
						</tr>
					</thead>
					<tbody id="selectable">
						<s:iterator value="reports" var="report">
							<tr <s:if test="lesson.id in #orderLessonQuery.lessonId">class="success"</s:if>>
								<td><s:property value="#orderLessonQuery.lessonId.length" /> ${report.lesson.timespan}</td>
								<td>${report.lesson.name}</td>
								<td><s:iterator value="lesson.teachings" var="teaching" status="status">
										<s:url action="listTeacherLesson" namespace="/schedule" id="listTeacherLesson">
											<s:param name="teacherId" value="teacher.id"></s:param>
											<s:param name="startDate" value="#startDate"></s:param>
											<s:param name="endDate" value="#endDate"></s:param>
										</s:url>
										<a href="${listTeacherLesson}">${teaching.teacher.name}</a>
										<s:if test="!#status.last">,</s:if>
									</s:iterator></td>
								<td>${report.lesson.classroom.name}</td>
								<td>${report.count} <a href="<s:property value="createUrl(lesson, #orderLessonQuery)" />" class="btn">
										<i class="icon-ok icon"></i>
									</a>
								</td>
							</tr>
						</s:iterator>
					</tbody>
				</table>
			</div>
			<div class="span4">
				<div class="form-inline">
					<label>学员</label>
					<select class="input-small">
						<option>姓名</option>
						<option>学号</option>
						<option>身份证</option>
						<option>驾驶证</option>
						<option>其他</option>
					</select> <input type="text" />
					<button type="button" class="btn btn-primary">订课</button>
				</div>
				<table class="table table-hover">
					<thead>
						<tr>
							<th>姓名</th>
							<th>学号</th>
							<th>卡号</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>张源</td>
							<td>13813181751</td>
							<td>贵宾卡20130302012</td>
						</tr>
						<tr>
							<td>张源</td>
							<td>13813181751</td>
							<td>雅思无限时</td>
						</tr>
					</tbody>
				</table>

				<span class="label label-success">正常</span>
				<ul>
					<li>
						<div>李欣(201303210981)</div>
						<div>贵宾卡(20123221212)</div>
						<div>9:00-11:30 雅思强化班-写作</div>
					</li>
				</ul>
				<span class="label label-important">补订</span>
				<ul>
					<li>
						<div>王华(201303210981)</div>
						<div>贵宾卡(20123221212)</div>
						<div>9:00-11:30 雅思强化班-写作</div>
					</li>
				</ul>
			</div>
		</div>
	</tiles:putAttribute>
</tiles:insertDefinition>